using System;
using System.Collections.Generic;
using System.Text;
using AF_ORM.CORE;
using System.Data;
namespace Tongiao.Manager
{
                

    public class Tg_ProductsManager:Tongiao.ManagerBase.Tg_ProductsManagerBase
    {
            public static Tg_ProductsManager CreateInstant()
            {
                return new Tg_ProductsManager();
            }

            public DataTable SearchPro(string ProductName, Guid CategoryId)
            {
                string strSql = "select P.*, C.CatName from tg_Products as P inner join tg_Category as C on P.CategoryId = C.id ";
                if ((CategoryId != Guid.Empty) && ProductName.Equals(""))
                    strSql += " where P.CategoryId = '" + CategoryId + "'";
                else if ((CategoryId == Guid.Empty) && !ProductName.ToString().Equals(""))
                    strSql += " where P.ProductName like N'%" + ProductName + "%'";
                else if ((CategoryId != Guid.Empty) && !ProductName.ToString().Equals(""))
                    strSql += " where P.CategoryId = '" + CategoryId + "' and P.ProductName like N'%" + ProductName + "%'";
                return SqlHelper.ExecuteDataTable(Config.ConnectionConfig.ConnectionString,CommandType.Text,strSql);
            }

           
    }
}
                    
